package com.example.shopping.controller.admin;

import com.example.shopping.pojo.User;
import com.example.shopping.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@RequestMapping("/admin")
@Controller
public class UserCon {
    @Autowired
    private UserService userService;

    @GetMapping("/userList")
    @ResponseBody
    public List<User> userList(){
        return userService.list();
    }

    @GetMapping("/delUser/{id}")
    @ResponseBody
    public void delUser(@PathVariable Integer id){
        userService.removeById(id);
    }
}
